using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;

/// <summary>
/// Summary description for ThamGiaDAO
/// </summary>
public class ThamGiaDAO:DataProvider
{
    public ArrayList LayMang_ThamGia()
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_ThamGia", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                ThamGiaDTO tgdto = new ThamGiaDTO();
                tgdto.MaDuAn_BaiBao = dr.GetInt32(0);
                tgdto.MaGV = dr.GetString(1);
                tgdto.VaiTro = dr.GetString(2);                
                arr.Add(tgdto);
            }


        }
        catch (Exception es)
        {
            throw es;
        }
        return arr;
    }
    public void insert(ThamGiaDTO tgdto)
    {
        connect();

        try
        {
            SqlCommand cmd = new SqlCommand("sp_Insert_ThamGia", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@magv", SqlDbType.NVarChar);
            cmd.Parameters["@magv"].Value = tgdto.MaGV.ToString();
            cmd.Parameters["@magv"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@vaitro", SqlDbType.NVarChar);
            cmd.Parameters["@vaitro"].Value = tgdto.VaiTro.ToString();
            cmd.Parameters["@vaitro"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@loai", SqlDbType.Int);
            cmd.Parameters["@loai"].Value = tgdto.Loai;
            cmd.Parameters["@loai"].Direction = ParameterDirection.Input;

            

            cmd.ExecuteNonQuery();
        }
        catch (Exception es)
        {
            throw es;
        }
    }
	public ThamGiaDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
